package demo2;
class Animal {
    String name;
    public Animal(String name) {
        this.name = name;
    }
}
interface IRunning {
    void run();
}
interface ISwimming {
    void swim();
}
interface IFlying {
    void fly();
}
class Dog extends Animal implements IRunning {
    public Dog(String name) {
        super(name);
    }
    @Override
    public void run() {
System.out.println(name+"正在用两条狗腿跑");
    }
}
class Fish extends Animal implements ISwimming {
    public Fish(String name) {
        super(name);
    }
    @Override
    public void swim() {
        System.out.println(name+"正在游泳");
    }
}
class Bird extends Animal implements IFlying {
    public Bird(String name) {
        super(name);
    }
    @Override
    public void fly() {
        System.out.println(name+"正在用翅膀飞");
    }
}
class Duck extends Animal implements IRunning,ISwimming,IFlying {
    public Duck(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(name+"正在用翅膀飞");
    }

    @Override
    public void run() {
System.out.println(name+"正在用两条腿跑");
    }

    @Override
    public void swim() {
System.out.println(name+"正在用两条腿游泳");
    }
}
class Robot implements IRunning {
    String name;
public Robot(String name) {
    this.name = name;
}
    @Override
    public void run() {
        System.out.println(name+"用两条机器腿跑");
    }
}

public class Test {
    public static void walk(IRunning irunning) {
        irunning.run();
    }
    public static void swim(ISwimming iswimming) {
        iswimming.swim();
    }
    public static void fly(IFlying iflying) {
        iflying.fly();
    }
    public static void main(String[] args) {
        walk(new Dog("旺财"));
        Duck duck = new Duck("唐老鸭");
        walk(duck);
        swim(duck);
        fly(duck);
        walk(new Robot("小智"));
        System.out.println("==============================");
        swim(new Fish("七秒"));
        fly(new  Bird("小鸟"));
    }
}
